//
//  SXWeatherModel.m
//  ShiXun
//
//  Created by lanou on 15/11/4.
//  Copyright © 2015年 张琪. All rights reserved.
//

#import "SXWeatherModel.h"

@implementation SXWeatherModel

- (void)setValue:(id)value forKey:(NSString *)key
{
    if ([key isEqualToString:@"weather"]) {
        _moreArray = [NSMutableArray array];
        for (NSDictionary *dic in value) {
            SXWeatherMoreModel *model = [[SXWeatherMoreModel alloc] init];
            [model setValuesForKeysWithDictionary:dic];
            [_moreArray addObject:model];
        }
    }
    else if ([key isEqualToString:@"life"])
    {
        NSDictionary *dict = value[@"info"];
        _indexArray = [NSMutableArray array];
        for (NSString *keyStr in dict) {
            SXWeatherIndexModel *model = [[SXWeatherIndexModel alloc] init];
            model.title = keyStr;
            model.introduction = dict[keyStr][0];
            model.dec = dict[keyStr][1];
            [_indexArray addObject:model];
        }
    }
    else if ([key isEqualToString:@"realtime"])
    {
        self.cityName = value[@"city_name"];
        self.info = value[@"weather"][@"info"];
        self.time = value[@"time"];
        self.temperature = value[@"weather"][@"temperature"];
        self.direct = value[@"wind"][@"direct"];
        self.power = value[@"wind"][@"power"];
    }
    else
    {
        [super setValue:value forKey:key];
    }
}

@end
